//
//  UIButton_Extension.swift
//  weibo
//
//  Created by Felix on 16/11/6.
//  Copyright © 2016年 Felix. All rights reserved.
//

import UIKit

extension UIButton {
    
    /*
     convenience 便利构造方法，没有这个修饰的是指定构造方法、指定构造方法在初始化时要对所有属性进行初始化
     便利构造方法依赖指定构造方法所以不用对属性进行初始化
     */
     convenience init(imageName:String , backgroundImageName:String) {
        self.init()
        
        setImage(UIImage.init(named: imageName), for: UIControlState.normal)
        setImage(UIImage.init(named: imageName+"_heighlighted"), for: UIControlState.highlighted)
        
        setBackgroundImage(UIImage.init(named: backgroundImageName), for: UIControlState.normal)
        
        setBackgroundImage(UIImage.init(named: backgroundImageName+"_heighlighted"), for: UIControlState.highlighted)
        
        sizeToFit()
}
}
